package  
{
	import flash.display.*;
	
	/**
	 * 路径环绕
	 * @author StefanieKaka
	 */
	public final class WindingDemo extends Sprite 
	{
		/// 构造函数
		public function WindingDemo() 
		{
			var commands : Vector.<int> = new Vector.<int>();
			var data1 : Vector.<Number> = new Vector.<Number>();
			
			commands.push(GraphicsPathCommand.MOVE_TO);
			commands.push(GraphicsPathCommand.LINE_TO);
			commands.push(GraphicsPathCommand.LINE_TO);
			commands.push(GraphicsPathCommand.LINE_TO);
			commands.push(GraphicsPathCommand.LINE_TO);
			
			commands.push(GraphicsPathCommand.MOVE_TO);
			commands.push(GraphicsPathCommand.LINE_TO);
			commands.push(GraphicsPathCommand.LINE_TO);
			commands.push(GraphicsPathCommand.LINE_TO);
			commands.push(GraphicsPathCommand.LINE_TO);
			
			data1.push(150, 100);
			data1.push(200, 100);
			data1.push(200, 250);
			data1.push(150, 250);
			data1.push(150, 100);
			
			/* 顺时针
			 * 0 → 1
			 * ↑   ↓
			 * 3 ← 2
			 */
			//data1.push(100, 150);
			//data1.push(250, 150);
			//data1.push(250, 200);
			//data1.push(100, 200);
			//data1.push(100, 150);
			
			/* 逆时针
			 * 0 ← 3
			 * ↓   ↑
			 * 1 → 2
			 */
			data1.push(100, 150);
			data1.push(100, 200);
			data1.push(250, 200);
			data1.push(250, 150);
			data1.push(100, 150);
			
			this.graphics.beginFill(0xff0000);
			this.graphics.drawPath(commands, data1, GraphicsPathWinding.NON_ZERO);
			this.graphics.endFill();
		}
		
	}

}